package com.wn.procurement.rabbitmq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqConfiguration {

    /**
     * @ param
     * @return org.springframework.amqp.core.TopicExchange
     * @ author lmz
     * @ date 2022/10/27 11:51
     * @ Description //声明交换机
     */
    @Bean
    public TopicExchange exchangeBookkeeping(){
        return new TopicExchange("exchangeprocurement");
    }
    /**
     * @param
     * @return org.springframework.amqp.core.Queue
     * @ author lmz
     * @ date 2022/10/27 11:52
     * @ Description 声明队列
     */
    @Bean
    public Queue queueeBookkeeping(){
        return new Queue("queueprocurement");
    }

    /**
     * @ param
     * @return org.springframework.amqp.core.Binding
     * @ author lmz
     * @ date 2022/10/27 11:54
     * @ Description 绑定队列到交换机
     */
    @Bean
    public Binding bindingemail(){
        return BindingBuilder.bind(queueeBookkeeping()).to(exchangeBookkeeping()).with("procurement");
    }

    //序列化转换器
    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }
}
